package com.maserb.monitor.dataCenter.communication;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class MonitorMessageEncoder extends MessageToByteEncoder<MonitorMessageProtocol> {
    protected void encode(ChannelHandlerContext tcx, MonitorMessageProtocol msg,
                          ByteBuf out) throws Exception {
        out.writeInt(MonitorMessageProtocol.HEAD_DATA);
        out.writeInt(msg.getContentLength());
        out.writeInt(msg.getContentType());
        out.writeBytes(msg.getContent());
    }
}
